export enum MobileBrands {
    IPHONE,
    HUAWEI,
    OPPO,
    VIVO,
    XIAOMI,
    SAMSUNG,
    MEIZU,
    UNKNOWN
}


export const getMobileBrand = () => {
    var ua = window.navigator.userAgent.toLowerCase();
    var isIphone = ua.match(/iphone/ig) != null;
    var isHuawei = ua.match(/huawei/ig) != null;
    var isHonor = ua.match(/honor/ig) != null;
    var isOppo = ua.match(/oppo/ig) != null;
    var isOppoR15 = ua.match(/pacm00/ig) != null;
    var isVivo = ua.match(/vivo/ig) != null;
    var isXiaomi = ua.match(/mi\s/ig) != null;
    var isXiaomi2s = ua.match(/mix\s/ig) != null;
    var isHm = ua.match(/hm/ig) != null;
    var isRedmi = ua.match(/redmi/ig) != null;
    var isSamsung = ua.match(/(gt-)|(sm-)|(sch-)/ig) != null;
    /GT-|SM-|SCH-/ig
    if (isIphone) {
        return MobileBrands.IPHONE;
    } else if (isHuawei || isHonor) {
        return MobileBrands.HUAWEI;
    } else if (isOppo || isOppoR15) {
        return MobileBrands.OPPO;
    } else if (isVivo) {
        return MobileBrands.VIVO;
    } else if (isXiaomi || isRedmi || isXiaomi2s || isHm) {
        return MobileBrands.XIAOMI;
    } else if (isSamsung) {
        return MobileBrands.SAMSUNG;
    } else {
        return MobileBrands.UNKNOWN;
    }
}
